﻿using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Dapper;
using BCEntity.OA.Attendance.AttendanceClassSetting;
using BCCommon;

namespace BCData.OA.Attendance.AttendanceClassSetting
{
    public class AttendanceClassSettingData : IAttendanceClassSettingData
    {
        private IDatabaseContext databaseContext;

        public AttendanceClassSettingData(IDatabaseContext databaseContext)
        {
            this.databaseContext=databaseContext;
        }

        /// <summary>
        /// 获取班次时间设置信息
        /// </summary>
        /// <param name="classId">班次Id</param>
        /// <returns></returns>
        public async Task<IEnumerable<AttendanceClassSettingEntity>> GetSettingsByClassIdAsync(long classId)
        {
            string sql = @"SELECT ClassSettingId,ClassId,Start,End 
                            FROM OA_AttendanceClassSetting  
                            WHERE ClassId=?ClassId;";
            DynamicParameters parameters = new DynamicParameters();
            parameters.Add("?ClassId", classId, DbType.Int64);
            return await this.databaseContext.Slave.QueryAsync<AttendanceClassSettingEntity>(sql, parameters);
        }
    }
}
